home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / triton / examples / EnvPrint.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-01  |  11.8 KB  |  362 lines

  1. Program EnvPrint;
  2.  
  3. (*
  4.  *  OpenTriton -- A free release of the triton.library source code
  5.  *  Copyright (C) 1993-1998  Stefan Zeiger
  6.  *
  7.  *  This program is free software; you can redistribute it and/or modify
  8.  *  it under the terms of the GNU General Public License as published by
  9.  *  the Free Software Foundation; either version 2 of the License, or
  10.  *  (at your option) any later version.
  11.  *
  12.  *  This program is distributed in the hope that it will be useful,
  13.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  *  GNU General Public License for more details.
  16.  *
  17.  *  You should have received a copy of the GNU General Public License
  18.  *  along with this program; if not, write to the Free Software
  19.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  *
  21.  *  envprint.c - Envprint 2.0 GUI created with Triton
  22.  *
  23.  *  As you can see below, it is possible to mix the tag format with
  24.  *  the C pre-processor macro format. (Actually I was just too lazy
  25.  *  to transform the whole project definition from tags to macros ;)
  26.  *
  27.  *)
  28.  
  29. {
  30.    A demo in FPC Pascal using triton.library
  31.  
  32.    nils.sjoholm@mailbox.swipnet.se
  33. }
  34.  
  35.  
  36. uses triton, tritonmacros, utility, vartags;
  37.  
  38.  
  39.  
  40. var
  41.     Triton_App : pTR_App;
  42.  
  43. PROCEDURE do_demo;
  44. VAR
  45.     close_me   : BOOLEAN;
  46.     trmsg      : pTR_Message;
  47.     dummy      : Longint;
  48.     Project    : pTR_Project;
  49.  
  50. BEGIN
  51.   ProjectStart;
  52.   WindowID(1); WindowPosition(TRWP_CENTERDISPLAY);
  53.   WindowTitle('EnvPrint 2.0 <THIS IS ONLY A NON-FUNCTIONAL GUI DEMO>');
  54.  
  55.   BeginMenu('Project');
  56.     BeginSub('Load');
  57.       SubItem('S_Load sender...',1);
  58.       SubItem('D_Load addressee...',2);
  59.       SubItem('C_Load comment...',3);
  60.     BeginSub('Save');
  61.       SubItem('O_Load sender',4);
  62.       SubItem('E_Load addressee',5);
  63.       SubItem('M_Load comment',6);
  64.     BeginSub('Sace as');
  65.       SubItem('U_Load sender as...',7);
  66.       SubItem('T_Load addressee as...',8);
  67.       SubItem('N_Load comment as...',9);
  68.     MenuItem('F_Delete file...',10);
  69.     ItemBarlabel;
  70.     MenuItem('P_Print...',11);
  71.     MenuItem('R_Preferences...',12);
  72.     ItemBarlabel;
  73.     MenuItem('?_About...',13);
  74.     ItemBarlabel;
  75.     MenuItem('Q_Quit',14);
  76.  
  77.   BeginMenu('Edit');
  78.     MenuItem('W_Swap',15);
  79.     MenuItem('X_Clear',16);
  80.  
  81.   HorizGroupA;
  82.     Space;
  83.     VertGroupA;
  84.       HorizGroupEAC;
  85.         VertGroupA;
  86.  
  87.           Space;
  88.  
  89.           NamedSeparatorI('Se_nder',101);
  90.  
  91.           SetTRTag(TROB_Space,          Longint(NIL));
  92.  
  93.           HorizGroup;
  94.             StringGadget(NIL,101);
  95.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  96.               GetEntryButtonS('_1',1101);
  97.               EndGroup;
  98.             EndGroup;
  99.  
  100.           SpaceS;
  101.  
  102.           HorizGroup;
  103.             StringGadget(NIL,102);
  104.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  105.               GetEntryButtonS('_2',1102);
  106.               EndGroup;
  107.             EndGroup;
  108.  
  109.           SpaceS;
  110.  
  111.           HorizGroup;
  112.             StringGadget(NIL,103);
  113.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  114.               GetEntryButtonS('_3',1103);
  115.               EndGroup;
  116.             EndGroup;
  117.  
  118.           SetTRTag(TROB_Space,          TRST_SMALL);
  119.  
  120.           HorizGroup;
  121.             StringGadget(NIL,104);
  122.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  123.               GetEntryButtonS('_4',1104);
  124.               EndGroup;
  125.             EndGroup;
  126.  
  127.           SetTRTag(TROB_Space,          TRST_SMALL);
  128.  
  129.           HorizGroup;
  130.             StringGadget(NIL,105);
  131.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  132.               GetEntryButtonS('_5',1105);
  133.               EndGroup;
  134.             EndGroup;
  135.  
  136.           SetTRTag(TROB_Space,          TRST_SMALL);
  137.  
  138.           HorizGroup;
  139.             StringGadget(NIL,106);
  140.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  141.               GetEntryButtonS('_6',1106);
  142.               EndGroup;
  143.             EndGroup;
  144.  
  145.           SetTRTag(TROB_Space,          TRST_SMALL);
  146.  
  147.           HorizGroup;
  148.             StringGadget(NIL,107);
  149.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  150.               GetEntryButtonS('_7',1107);
  151.               EndGroup;
  152.             EndGroup;
  153.  
  154.           SetTRTag(TROB_Space,          TRST_SMALL);
  155.  
  156.           HorizGroup;
  157.             StringGadget(NIL,108);
  158.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  159.               GetEntryButtonS('_8',1108);
  160.               EndGroup;
  161.             EndGroup;
  162.  
  163.           SetTRTag(TROB_Space,          Longint(NIL));
  164.  
  165.           SetTRTag(TRGR_End,            Longint(NIL));
  166.  
  167.         SetTRTag(TROB_Space,            Longint(NIL));
  168.  
  169.         SetTRTag(TRGR_Vert,             TRGR_PROPSHARE OR TRGR_ALIGN);
  170.  
  171.           SetTRTag(TROB_Space,          Longint(NIL));
  172.  
  173.           NamedSeparatorI('Add_ressee',201);
  174.  
  175.           SetTRTag(TROB_Space,          Longint(NIL));
  176.  
  177.           HorizGroup;
  178.             StringGadget(NIL,201);
  179.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  180.               GetEntryButtonS('_!',1201);
  181.               EndGroup;
  182.             EndGroup;
  183.  
  184.           SpaceS;
  185.  
  186.           HorizGroup;
  187.             StringGadget(NIL,202);
  188.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  189.               GetEntryButtonS('_''',1202);
  190.               EndGroup;
  191.             EndGroup;
  192.  
  193.           SpaceS;
  194.  
  195.           HorizGroup;
  196.             StringGadget(NIL,203);
  197.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  198.               GetEntryButtonS('_ยง',1203);
  199.               EndGroup;
  200.             EndGroup;
  201.  
  202.           SetTRTag(TROB_Space,          TRST_SMALL);
  203.  
  204.           HorizGroup;
  205.             StringGadget(NIL,204);
  206.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  207.               GetEntryButtonS('_$',1204);
  208.               EndGroup;
  209.             EndGroup;
  210.  
  211.           SetTRTag(TROB_Space,          TRST_SMALL);
  212.  
  213.           HorizGroup;
  214.             StringGadget(NIL,205);
  215.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  216.               GetEntryButtonS('_%%',1205);
  217.               EndGroup;
  218.             EndGroup;
  219.  
  220.           SetTRTag(TROB_Space,          TRST_SMALL);
  221.  
  222.           HorizGroup;
  223.             StringGadget(NIL,206);
  224.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  225.               GetEntryButtonS('_&',1206);
  226.               EndGroup;
  227.             EndGroup;
  228.  
  229.           SetTRTag(TROB_Space,          TRST_SMALL);
  230.  
  231.           HorizGroup;
  232.             StringGadget(NIL,207);
  233.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  234.               GetEntryButtonS('_/',1207);
  235.               EndGroup;
  236.             EndGroup;
  237.  
  238.           SetTRTag(TROB_Space,          TRST_SMALL);
  239.  
  240.           HorizGroup;
  241.             StringGadget(NIL,208);
  242.             SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  243.               GetEntryButtonS('_(',1208);
  244.               EndGroup;
  245.             EndGroup;
  246.  
  247.           SetTRTag(TROB_Space,          Longint(NIL));
  248.  
  249.           SetTRTag(TRGR_End,            Longint(NIL));
  250.  
  251.         SetTRTag(TRGR_End,              Longint(NIL));
  252.  
  253.       NamedSeparatorI('Co_mment',301);
  254.  
  255.       SetTRTag(TROB_Space,              Longint(NIL));
  256.  
  257.       HorizGroup;
  258.         StringGadget(NIL,301);
  259.         SetTRTag(TRGR_Horiz,0 OR TRGR_FIXHORIZ);;
  260.           GetEntryButtonS('_0',1301);
  261.           EndGroup;
  262.         EndGroup;
  263.  
  264.       SetTRTag(TROB_Space,              Longint(NIL));
  265.  
  266.       SetTRTag(TRGR_End,                Longint(NIL));
  267.  
  268.     SetTRTag(TROB_Space,                Longint(NIL));
  269.     SetTRTag(TROB_Line,                 TROF_VERT OR TROF_RAISED);
  270.  
  271.     SetTRTag(TROB_Space,                TRST_BIG);
  272.  
  273.     SetTRTag(TRGR_Vert,                 TRGR_PROPSHARE OR TRGR_ALIGN OR TRGR_FIXHORIZ);
  274.       SetTRTag(TROB_Space,              Longint(NIL));
  275.       SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE OR TRGR_CENTER);
  276.         SetTRTag(TROB_Line,             TROF_HORIZ);
  277.         SetTRTag(TROB_Space,            Longint(NIL));
  278.         SetTRTag(TROB_Text,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('Load')); SetTRTag(TRAT_Flags, TRTX_TITLE);
  279.         SetTRTag(TROB_Space,            Longint(NIL));
  280.         SetTRTag(TROB_Line,             TROF_HORIZ);
  281.         SetTRTag(TRGR_End,              Longint(NIL));
  282.       SetTRTag(TROB_Space,              Longint(NIL));
  283.       SetTRTag(TROB_Button,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('_Sender...')); SetTRTag(TRAT_ID, 501);
  284.       SetTRTag(TROB_Space,              TRST_SMALL);
  285.       SetTRTag(TROB_Button,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('_Addressee...')); SetTRTag(TRAT_ID, 502);
  286.       SetTRTag(TROB_Space,              TRST_SMALL);
  287.       SetTRTag(TROB_Button,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('_Comment...')); SetTRTag(TRAT_ID, 503);
  288.       SetTRTag(TROB_Space,              Longint(NIL));
  289.       SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE OR TRGR_CENTER);
  290.         SetTRTag(TROB_Line,             TROF_HORIZ);
  291.         SetTRTag(TROB_Space,            Longint(NIL));
  292.         SetTRTag(TROB_Text,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('Save')); SetTRTag(TRAT_Flags, TRTX_TITLE);
  293.         SetTRTag(TROB_Space,            Longint(NIL));
  294.         SetTRTag(TROB_Line,             TROF_HORIZ);
  295.         SetTRTag(TRGR_End,              Longint(NIL));
  296.       SetTRTag(TROB_Space,              Longint(NIL));
  297.       SetTRTag(TROB_Button,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('S_ender...')); SetTRTag(TRAT_ID, 504);
  298.       SetTRTag(TROB_Space,              TRST_SMALL);
  299.       SetTRTag(TROB_Button,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('A_ddressee...')); SetTRTag(TRAT_ID, 505);
  300.       SetTRTag(TROB_Space,              TRST_SMALL);
  301.       SetTRTag(TROB_Button,             Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('C_omment...')); SetTRTag(TRAT_ID, 506);
  302.       SetTRTag(TROB_Space,              TRST_BIG);
  303.       SetTRTag(TROB_Line,               TROF_HORIZ);
  304.       SetTRTag(TROB_Space,              TRST_BIG);
  305.       SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE);
  306.         SetTRTag(TROB_Button,           Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('_Print...')); SetTRTag(TRAT_ID, 507);
  307.         SetTRTag(TROB_Space,            TRST_SMALL);
  308.         SetTRTag(TROB_Button,           Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('S_wap')); SetTRTag(TRAT_ID, 508);
  309.         SetTRTag(TRGR_End,              Longint(NIL));
  310.       SetTRTag(TROB_Space,              TRST_SMALL);
  311.       SetTRTag(TRGR_Horiz,              TRGR_EQUALSHARE);
  312.         SetTRTag(TROB_Button,           Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('Pre_fs...')); SetTRTag(TRAT_ID, 509);
  313.         SetTRTag(TROB_Space,            TRST_SMALL);
  314.         SetTRTag(TROB_Button,           Longint(NIL)); SetTRTag(TRAT_Text,  LongStr('C_lear')); SetTRTag(TRAT_ID, 510);
  315.         SetTRTag(TRGR_End,              Longint(NIL));
  316.       SetTRTag(TROB_Space,              Longint(NIL));
  317.     SetTRTag(TRGR_End,                  Longint(NIL));
  318.  
  319.     SetTRTag(TROB_Space,                Longint(NIL));
  320.  
  321.   SetTRTag(TRGR_End,                    Longint(NIL));
  322.  
  323.   EndProject;
  324.  
  325.   Project := TR_OpenProject(Triton_App,@tritontags);
  326.     IF Project <> NIL THEN BEGIN
  327.       close_me := FALSE;
  328.       WHILE NOT close_me DO BEGIN
  329.         dummy := TR_Wait(Triton_App,0);
  330.         REPEAT
  331.           trmsg := TR_GetMsg(Triton_App);
  332.           IF trmsg <> NIL THEN BEGIN
  333.             IF (trmsg^.trm_Project = Project) THEN BEGIN
  334.                CASE trmsg^.trm_Class OF
  335.                  TRMS_CLOSEWINDOW : close_me := True;
  336.                  TRMS_ERROR:        WriteLN(TR_GetErrorString(trmsg^.trm_Data));
  337.                END;
  338.             END;
  339.             TR_ReplyMsg(trmsg);
  340.           END;
  341.         UNTIL close_me OR (trmsg = NIL);
  342.       END;
  343.       TR_CloseProject(Project);
  344.     END ELSE WriteLN(TR_GetErrorString(TR_GetLastError(Triton_App)));
  345. END;
  346.  
  347. begin
  348.   Triton_App := TR_CreateApp(TAGS(
  349.                 TRCA_Name,longstr('Envprint'),
  350.                 TRCA_LongName,longstr('EnvPrint GUI demo'),
  351.                 TRCA_Version,longstr('2.0'),
  352.                 TAG_END));
  353.   
  354.   if Triton_App <> nil then begin
  355.      do_demo;
  356.      TR_DeleteApp(Triton_App);
  357.   END
  358.   ELSE writeln('Can''t create application');
  359. END.
  360.  
  361.  
  362.